/*
 * Copyright 2007-2009 Perttu "celeron55" Ahola <celeron55@gmail.com>
 *
 * This file is part of jukumagic.
 *
 * jukumagic is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * jukumagic is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with jukumagic.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef FOOTPRINT_H_
#define FOOTPRINT_H_

#include "common.h"
#include "objectcontainer.h"
#include "boardobject.h"
#include <list>

class Footprint : public JukuObject
{
	/*std::list<BoardRect> m_boardrect_block_area;
	bool m_boardrect_block_area_is_valid;
	void MakeBoardRectBlockArea();*/
	//void ChildChanged(ObjectChangeType type, JukuObject *obj);
public:
	BoardSide m_side;
	ObjectContainer m_graphics;
	ObjectContainer m_block_area;
	ObjectContainer m_pins;
	wxString m_name;
	wxString m_subname;
	Footprint();
	Footprint(Footprint &footprint);
	~Footprint();
    JukuObjectType GetType(){ return TYPE_FOOTPRINT; }
	const wxChar * GetShortString(void){return NULL;}
	const wxChar * GetTypeString(void){return _("Footprint");}
 	JukuObject* MakeACopy();
	void WriteXML(TiXmlNode* root);
	static JukuObject* ReadFromXMLElement(TiXmlElement* element);
	void Draw(wxDC &dc, wxWindow *window, wxPoint origin);
	BoardRect GetDrawArea();
	//std::list<BoardRect> GetBlockArea();

	bool IsSelectedInPoint(int x, int y);
	bool IsSelectedInArea(int x1, int y1, int x2, int y2, bool touch_is_enough);

	void SetSelected(bool selected);

	void Rotate(TurnDirection dir, BoardPoint origin);
	//void Rotate180();
	
	void Move(int dx, int dy);

	BoardRect GetPinExtents();
	
	//simplify internal coordinates
	//removes the values added to internal from masterpos
	void SimplifyCoordinates(BoardPoint *masterpos);
};

enum FootprintType
{
	FOOTPRINT_UNKNOWN,
	FOOTPRINT_ACY,
	FOOTPRINT_ALF,
	FOOTPRINT_ACC,
	FOOTPRINT_RCY,
};

extern Footprint* MakeTwoWireFootprint(FootprintType type, int length, int size);

#endif
